// 导入封装的 request 函数
import request from "@/utils/request";

// 创建订单
export function ordersCreate(data) {
  return request({
    method: "POST",
    url: "/my/orders/create",
    // 请求头携带 token 信息
    header: {
      Authorization: uni.getStorageSync("userProfile").token,
    },
    data: data,
  });
}

// 根据订单号生成订单支付参数
export function ordersPayInfo(order_number) {
  return request({
    method: "POST",
    url: "/my/orders/req_unifiedorder",
    // 请求头携带 token 信息
    header: {
      Authorization: uni.getStorageSync("userProfile").token,
    },
    data: {
      order_number: order_number,
    },
  });
}

// 检查并更新订单的支付状态
export function ordersCheck(order_number) {
  return request({
    method: "POST",
    url: "/my/orders/chkOrder",
    // 请求头携带 token 信息
    header: {
      Authorization: uni.getStorageSync("userProfile").token,
    },
    data: {
      order_number: order_number,
    },
  });
}
